#!/bin/bash
read -p "请输入输入进制,默认为10:" in
if [[ -z "$in" ]];then
    in=10
fi
read -p "请输入输出进制,默认为2:" out
if [[ -z "$out" ]];then
    out=2
fi
read -p "请输入值:" number
result=$(echo "ibase=$in;obase=$out;$number"|bc)
if [[ $? -eq 0 ]];then
    echo "结果:$result"
else
    echo "计算出错"
fi

